find longest common prefix of array